<?php
$input= "A !@#$%^&*S 34 B";
echo $output = preg_replace("/[^A-Za-z0-9]/"," ",$input);  

?>